<?php
class TechnicCron{

	function updateTechnic($param)
	{
		global $host,$dbTable, $dbPass,$dbId;

		$host = "localhost";

        $dbId = "root";

        $dbPass = "";

        $dbTable = "Bloodwar";
   	    $link = mysql_connect($host,$dbId,$dbPass);

        mysql_select_db($dbTable);
		mysql_query("SET names UTF8");
		
        $sql="select * from mem_technic_upgrading where state_endtime < unix_timestamp()";
		$result=mysql_query($sql);
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			
            $sql = "update sys_technic set level =".$row["level"].", state = 0 where id = ".$row["id"];

			mysql_query($sql);

		
	        $sql = "DELETE FROM mem_technic_upgrading WHERE id=".$row["id"];
            mysql_query($sql);
		
        }

		mysql_close($link);

		return $param;

	}
}
?>